package com.tengju.bff.interfaces.app.user;

import com.tengju.bff.interfaces.app.user.facade.StarInfoFacade;
import com.tengju.bff.interfaces.app.user.vo.UserInfoVO;
import com.tengju.bff.interfaces.app.user.vo.UserStarSuperiorSecVO;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.servlet.NotTokenValid;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chenhang
 * @Date 2021/1/6
 */
@Validated
@RestController
@Api(tags = "星级信息查询")
@RequestMapping(value = "app/user")
@Slf4j
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class StarInfoController {

    private final StarInfoFacade starInfoFacade;

    @ApiOperation(value = "获取所属sec信息", notes = "获取所属sec信息")
    @RequestMapping(value = "getSuperiorSec", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @NotTokenValid
    public ApiResponse<UserStarSuperiorSecVO> getSuperiorSec(@RequestParam(value = "idCode") Long idCode) {
        return ApiResponse.newSuccess(starInfoFacade.getSuperiorSec(idCode));
    }

    @ApiOperation(value = "获取sec列表", notes = "获取sec列表")
    @RequestMapping(value = "listSec", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @NotTokenValid
    public ApiResponse<List<UserInfoVO>> listSec(@RequestParam(value = "pageNo") Integer pageNo,
                                                 @RequestParam(value = "pageSize") Integer pageSize) {
        return ApiResponse.newSuccess(starInfoFacade.listSec(pageNo,pageSize));
    }



}
